import {lazy} from 'react'
import { Navigate, useRoutes } from 'react-router-dom'
// 使用路由懒加载 lazy
const Login=lazy(()=>import('../page/login/login'))
const Home=lazy(()=>import('../page/home/home'))
const HomePage=lazy(()=>import('../page/home/home_page'))
const Visitor=lazy(()=>import('../page/visitor/visitor'))
const Set=lazy(()=>import('../page/set/set'))
const NotFount=lazy(()=>import('../page/NotFount'))
const Routes = () => {
  return useRoutes([
    {
      path: '/',
      element: <Navigate to='/login'/>
    },
    {
      path: '/login',
      element: <Login />
    },
    {
      path: '/home',
      element: <Home />,
      children: [
        {
          path: '',
          index: true,
          element: <HomePage />
        }, 
        {
          path: 'visitor',
          element: <Visitor />
        },
        {
          path: 'set',
          element: <Set />
        }
      ]
    },
    {
      path: '/*',
      element: <NotFount />
      
    }
  ])
}
export default Routes